<?php

namespace App\Http\Middleware;

use Closure;
use Auth;
class CheckLogin
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        //判断用户是否登录,如果登录了,不管它,如果没登录,打回去,让他去登录
        if(!Auth::check()){
            session()->flash('danger','请先进行登录');
            return redirect()->route('login');
        }

        return $next($request);
    }
}
